package day12;

import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.Scanner;

public class Demo2 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] nums = new int[3];
        //catch可以写多个 切记:一般情况下  先捕获子类异常
        //再捕获父类异常  也可以写同级异常  不可以反过来编写
        try{
        for (int i = 0; i < 3; i++) {
            System.out.println("请输入一个数字");
            nums[i] = sc.nextInt();

        }
            System.out.println("数组赋值成功"+ Arrays.toString(nums));
        }
        catch(InputMismatchException e){
            System.out.println(e);
        }
        finally {
            System.out.println("ok");
        }
    }
}
